# Makefile for boingwm
#
#  Scott Lawrence
#  yorgle@gmail.com
#  http://umlautllama.com/
#
# Originally WindowLab
#

PROJNAME := boingwm

# Comment out to remove shape support (for X11R5 or just a tiny bin)
DEFINES += -DSHAPE
EXTRA_LIBS += -lXext

# Set this to the hardcoded location of all files if it's not /
PREFIX =

# Set this to the location of the X installation you want to compile against
XROOT = /usr/X11R6

# Set this to the location of the global configuration files
SYSCONFDIR = $(PREFIX)/etc/X11/$(PROJNAME)

# Information about the location of the menurc file
MENURC ?= $(SYSCONFDIR)/$(PROJNAME).menurc

DEFINES += -DDEF_MENURC="\"$(MENURC)\""

# Uncomment to add MWM hints support
#DEFINES += -DMWM_HINTS

# Uncomment to add freetype support (requires XFree86 4.0.2 or later)
# This needs -lXext above, even if you have disabled shape support
#DEFINES += -DXFT
#EXTRA_INC += `pkg-config --cflags xft`
#EXTRA_LIBS += `pkg-config --libs xft`

# Uncomment for debugging info (abandon all hope, ye who enter here)
#DEFINES += -DDEBUG

# --------------------------------------------------------------------

CC = gcc
CFLAGS ?= -g -O2 -Wall -pedantic -W

BINDIR = $(DESTDIR)$(PREFIX)$(XROOT)/bin
MANDIR = $(DESTDIR)$(PREFIX)$(XROOT)/man/man1
CFGDIR = $(DESTDIR)$(SYSCONFDIR)
INCLUDES = -I$(XROOT)/include $(EXTRA_INC) -Isrc
LDPATH = -L$(XROOT)/lib
LIBS = -lX11 $(EXTRA_LIBS)

PROG = $(PROJNAME)
MANPAGE = $(PROJNAME).1x
HEADERS = \
	src/$(PROJNAME).h
OBJS = \
	src/main.o \
	src/events.o \
	src/client.o \
	src/new.o \
	src/manage.o \
	src/misc.o \
	src/taskbar.o \
	src/menufile.o \
	\
	src/gradient.o

all: $(PROG)

$(PROG): $(OBJS)
	@echo Linking $@
	@$(CC) $(OBJS) $(LDPATH) $(LIBS) -o $@

$(OBJS): %.o: %.c $(HEADERS)
	@echo Compiling $@
	@$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

install: all
	@echo Installing
	@mkdir -p $(BINDIR) && install -m 755 -s $(PROG) $(BINDIR)
	@mkdir -p $(MANDIR) && install -m 644 $(MANPAGE) $(MANDIR) && gzip -9vfn $(MANDIR)/$(MANPAGE)
	@mkdir -p $(CFGDIR) && cp -i $(PROJNAME).menurc $(CFGDIR)/$(PROJNAME).menurc && chmod 644 $(CFGDIR)/$(PROJNAME).menurc

clean:
	@echo Cleaning - removing $(PROG) and .o files
	@rm -f $(PROG) $(OBJS)

.PHONY: all install clean
